﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace centraldba_dbrestore_utility
{
    public delegate void DateSelectedHandler(object sender, DateEventArgs e);

    /// <summary>
    /// Interaction logic for frmPickDate.xaml
    /// </summary>
    public partial class frmPickDate : Window
    {
        public event DateSelectedHandler DateSelected;

        public frmPickDate(DateTime startingDate)
        {
            InitializeComponent();
            DateSelector.SelectedDate = startingDate;
        }

        protected virtual void OnDateSelected(DateEventArgs e)
        {
            if (DateSelected != null)
                DateSelected(this, e);
        }

        private void DateSelector_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            DateEventArgs dea = new DateEventArgs();
            dea.SelectedDate = Convert.ToDateTime(e.AddedItems[0]);
            OnDateSelected(dea);
        }

        private void OK_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
